<?php
class Admin_Model_Account extends Zend_Db_Table_Abstract
{
	protected $_name = 'ha_users';
	public function __construct($config = array()) {
       $this->db = Zend_Db_Table::getDefaultAdapter();
        parent::__construct($config);
    }
	private function Table()
	{
	$userTable = new Zend_Db_Table('ha_users');
	return $userTable;
	}
    
	 public function SelectAll(){
	
		$select = $this->Table()->select();
        return $this->Table()->fetchAll($select);
    }
    public function SelectAll1(){
		$sql = sprintf("select * from ha_users");
		$stmt = $this->db->query($sql);
		return $stmt;
    }	
// lay ra thong tin tài khoản
	  public function getNews($id)
	    {
	        $id = (int)$id;
	        $row = $this->fetchRow('ID_U = ' . $id);
	        if (!$row) {
	            throw new Exception("Could not find row $id");
	        }
	        return $row->toArray();
	    }		
	
	 // cap nhat tài khoản
	  public function updateNews($USERNAME,$EMAIL,$FULLNAME,$ID)
    {

        $data = array(
				'USERNAME' => $USERNAME,
				
				'EMAIL'=>$EMAIL,
				'FULLNAME' => $FULLNAME,
				
				);
				
		try
		{
		$this->Table()->update($data, "ID_U=".$ID);
		}
		catch(Exception $e)
		{
			echo $e->__toString();
			exit;
			
		}
		
    }
	 public function updatepassword($PASSWORD,$ID=2)
    {

        $data = array(
				
				'PASSWORD' => $PASSWORD,
								
				);
				
		try
		{
		$this->Table()->update($data, "ID_U=".$ID);
		}
		catch(Exception $e)
		{
			echo $e->__toString();
			exit;
			
		}
		
    }
	
}